package com.lyeducation.entities.course.middle;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects;


@MappedSuperclass
@IdClass(UserVideoEntityPK.class)
public abstract class AbstractUserVideoEntity implements Serializable {
    private String userId;
    private String videoId;
    private Timestamp createTime;

    @Id
    @Column(name = "userId", nullable = false, length = 18)
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Id
    @Column(name = "videoId", nullable = false, length = 18)
    public String getVideoId() {
        return videoId;
    }

    public void setVideoId(String videoId) {
        this.videoId = videoId;
    }

    @Basic
    @Column(name = "createTime", nullable = true)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof AbstractUserVideoEntity)) {
            return false;
        }
        AbstractUserVideoEntity that = (AbstractUserVideoEntity) o;
        return Objects.equals(userId, that.userId) &&
                Objects.equals(videoId, that.videoId) &&
                Objects.equals(createTime, that.createTime);
    }

    @Override
    public int hashCode() {

        return Objects.hash(userId, videoId, createTime);
    }
}


